/************************************************************************/
// Copyright (C) 2016, han_gangbiao. All rights reserved.
// Use of this source code is governed by a GPL-v2 license that can be found in the License file.
// 
// [Time]:      2016-1-4 21:53:17
// [Author]:    han_gangbiao [http://my.oschina.net/jackhen]
// [Info]:      
/************************************************************************/

#ifndef INCLUDE_BASE_XATOMIC_H_
#define INCLUDE_BASE_XATOMIC_H_

#include "baseheader.h"

BEG_NS_SMART

class atomic_t
{
public:
    atomic_t():m_value(0) { }
    
public:
    long get() const;
    long set(long v);   //return old value
    long inc();         //return new value
    long dec();         //return new value
    bool cas(long cmp, long newvalue);
private:
    volatile long m_value;
};

END_NS_SMART

#endif //~INCLUDE_BASE_XATOMIC_H_
